package com.lowang.guava.test;

import java.util.LinkedList;

/**
 * @author Lo&Wang
 */
public class TrieNode {
    /**
     * 字符串内容.
     */
    private char content;
    /**
     * 单词次数.
     */
    private int count;
    /**
     * 单词长度.
     */
    private int length;
    /**
     * 结尾.
     */
    private boolean end;
    /**
     * 子节点
     */
    LinkedList<TrieNode> children;

    public TrieNode(char c) {
        this.content = c;
        this.length = 0;
        this.count = 0;
        this.children = new LinkedList<TrieNode>();
        this.end = false;
    }

    public TrieNode subNode(char c) {
        if (this.children.isEmpty()) {
            return null;
        }
        for (TrieNode node : this.children) {
            if (node.getContent() == c) {
                return node;
            }
        }
        return null;
    }

    /**
     * @return the content
     */
    public char getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(char content) {
        this.content = content;
    }

    /**
     * @return the count
     */
    public int getCount() {
        return count;
    }

    /**
     * @param count the count to set
     */
    public void setCount(int count) {
        this.count = count;
    }

    /**
     * @return the length
     */
    public int getLength() {
        return length;
    }

    /**
     * @param length the length to set
     */
    public void setLength(int length) {
        this.length = length;
    }

    /**
     * @return the children
     */
    public LinkedList<TrieNode> getChildren() {
        return children;
    }

    /**
     * @param children the children to set
     */
    public void setChildren(LinkedList<TrieNode> children) {
        this.children = children;
    }

    /**
     * @return the end
     */
    public boolean isEnd() {
        return end;
    }

    /**
     * @param end the end to set
     */
    public void setEnd(boolean end) {
        this.end = end;
    }

}
